package com.modelscope.ai.config;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

/**
 * @author xiawei
 * @date 2020/8/10 11:33
 */
@Component
@RefreshScope
@Data
public class OssConfig implements InitializingBean {

    @Value("${oss.endpoint}")
    private String endpoint;

    @Value("${oss.keyid}")
    private String keyId;

    @Value("${oss.keysecret}")
    private String keySecret;

    @Value("${oss.bucketname}")
    private String bucketName;

    public static String END_POINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;

    /**
     * 当项目启动后，Spring会将上面的值注入，然后执行以下方法：
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        END_POINT = endpoint;
        ACCESS_KEY_ID = keyId;
        ACCESS_KEY_SECRET = keySecret;
        BUCKET_NAME = bucketName;
    }

}